using System;
using System.Web.UI.WebControls;
using THANHTUNGO.Portal.Components.Helpers;
using THANHTUNGO.Portal.Components.UI;

namespace THANHTUNGO.Portal.Modules.NEWS.Controls
{
    public partial class Detail : YAFPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["itemid"] != null)
                {
                    int itemID = Convert.ToInt32(Request.QueryString["itemid"]);
                    //Item.ViewCounter(itemID);
                    Components.Item item = Components.Item.Load(itemID);
                    if (item != null)
                    {
                        lblTitle.Text = item.Title;
                        lblPublishedTime.Text = item.PublishedTime.ToLongDateString() + " - " + item.Authors;
                        lblTotalViews.Text = item.TotalViews.ToString("N0");
                        ltrRate.Text = ImageHelper.BuildRateImage(item.Rate, Request);
                        lblContent.Text = Server.HtmlDecode(item.Content);
                    }
                }
            }
        }

        protected void dlRelationItem_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                YAFUrlBuilder.Redirect(this.ModuleID, ModulePages.Detail, "itemid={0}", e.CommandArgument.ToString());
            }
        }
    }
}